<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/gray/window.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
		<script type="text/javascript" src="../../../JS/BasicInfomation.js"></script>
	</head>

	<body style="padding: 0px;">
		<form id="ff" method="post">
			<table cellpadding="6" class="displaytable" style="padding: 20px;">
				<tr>
					<td width="33%">
						<h id="star">* </h>用户组
					</td>
					<td width="67%">
						<input id="input_CUSTOMER_TYPE" style="width:100%" class="easyui-combobox" name="CUSTOMER_TYPE" >
						</input>
					</td>
				</tr>
				<tr>
					<td width="33%">
						<h id="star">* </h>配送单位名称
					</td>
					<td width="67%">
						<input class="easyui-textbox" style="width:100%;height:25px" name="CUSTOMER_NAME" data-options="required:'true'">
						</input>
					</td>
				</tr>
				<tr>
					<td width="33%">
						<h id="star">* </h>联系人姓名</td>
					<td width="67%"><input style="width:100%;height:25px" type="text" class="easyui-textbox" name="CONTACT_NAME" data-options="required:'true'"></input>
					</td>
				</tr>
				<tr>
					<td width="33%">
						<h id="star">* </h>联系人电话</td>
					<td width="67%">
						<input id="_phonenumber" class="easyui-textbox" name="CONTACT_TEL" style="width:100%;height:25px" data-options="prompt:'请输入您的手机号码',required:true" ,valueField: 'CONTACT_TEL',textField: 'CONTACT_TEL'></input>
					</td>
				</tr>
				<tr>
					<td width="33%">
						<h id="star">* </h>监督电话</td>
					<td width="67%">
						<input id="_phonenumber" class="easyui-textbox" name="CONTACT_TEL" style="width:100%;height:25px" data-options="prompt:'请输入您的手机号码',required:true" ,valueField: 'CONTACT_TEL',textField: 'CONTACT_TEL'></input>
					</td>
				</tr>
				<tr>
					<td width="33%">
						<h id="star">* </h>V网</td>
					<td width="67%">
						<input id="_phonenumber" class="easyui-textbox" name="CONTACT_TEL" style="width:100%;height:25px" data-options="prompt:'请输入您的手机号码',required:true" ,valueField: 'CONTACT_TEL',textField: 'CONTACT_TEL'></input>
					</td>
				</tr>
				<tr class="hiddentr">
					<td>ID</td>
					<td>
						<input style="width:100%" class="easyui-textbox" name="ID"></input>
					</td>
				</tr>
				<tr class="hiddentr">
					<td>用户组ID</td>
					<td>
						<input id="input_CUSTOMERTYPE_ID" style="width:90%;height:25px" class="easyui-textbox" name="TYPE_ID"></input>
					</td>
				</tr>
			</table>
			<table>
				<div class="submit_button">
					<a class="easyui-linkbutton" onclick="save()" style="width: 100px;"> 保存</a>
					<a class="easyui-linkbutton" onclick="cls()" style="width: 100px;margin-left: 10px;">清空 </a>
				</div>
			</table>
		</form>
	</body>
	<script type="text/javascript">
		var id = getID();
		$(document).ready(function(){
			if(id != AddFlag) {
			loadRemote();
		}
		});

		function save() {
			var msg = checkPhoneNumber($("#_phonenumber").val());
			if(msg != "验证成功") {
				$.messager.alert("警告", msg);
				return;
			}
			var isValid = $("#ff").form('validate');
			if(!isValid) {
				$.messager.alert("警告", "有必填项没有填写");
				return ;
			}
			saveData();
		}

		function loadRemote() {
			var pLocation = RemoteLinkAddress + '/logistics/customer/findbyid.do?ID=' + id;
			$('#ff').form('load', pLocation);
		}

		function saveData() {
			var _url = '';
			data = $("#ff").serialize();
			if(id == AddFlag) {
				_url = RemoteLinkAddress + '/logistics/customer/save.do';
				data=data.replace("&ID=",""); //在新增保存的时候不需要传入ID值
			} else {
				_url = RemoteLinkAddress + '/logistics/customer/update.do'
			}
			
			$.post(_url, data,
				function(result) {
					if(result.msg === "success") {
						var parentLocation;
						parentLocation = searchParent("BasicInformationOrderUnitList.html");
						parentLocation.dialogClose();
						$.messager.alert({ // show error message
							title: '成功',
							msg: '添加成功'
						});
					} else {
						$.messager.alert({
							title: '警告',
							msg: '输入的数据'+result.msg+'已存在'
						})
					}
				}, 'json');
		}

		function cls() {
			$('#ff').form('reset');
		}
		$('#input_CUSTOMER_TYPE').combobox({
			valueField: 'CUSTOMER_TYPE',
			textField: 'CUSTOMER_TYPE',
			panelWidth: 200,
			panelHeight: 'auto',
			mode: 'remote',
			method: 'get',
			url: RemoteLinkAddress + "/logistics/customertype/listall.do",
			onSelect: function(record) { //当选中数据后调用该function，并得到该combobox对应的valuefield和textfield，赋值给record
					$('#input_CUSTOMERTYPE_ID').textbox('setValue', record.ID);
				} //调用easyui的textbox的写入值方法，将record中name为CUSTOMER_ID的写入id为customer_id的textbox中
		});
	</script>
</html>